import {createRouter, createWebHashHistory} from "vue-router";
import Home from "../views/Home.vue";

const routes = [
    {
        path: '/',
        redirect: '/dashboard'
    }, {
        path: "/",
        name: "Home",
        component: Home,
        children: [
            {
                path: '/result',
                name: '/result',
                meta: {
                    title: '问卷结果'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/firstVisit/Result.vue")
            },
            {
                path: '/application',
                name: '/application',
                meta: {
                    title: '咨询申请'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/dict//application.vue")
            },
            {
                path: '/recordlog',
                name: '/recordlog',
                meta: {
                    title: '咨询记录表'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/consult/recordlog.vue")
            },
            {
                path: '/firstresult',
                name: '/firstresult',
                meta: {
                    title: '初访结果'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/firstVisit/first_visit_result.vue")
            },
            {
                path: '/consultPage',
                name: '/consultPage',
                meta: {
                    title: '咨询列表'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/consult/consultPage.vue")
            },
            {
                path: '/closedReport',
                name: 'closedReport',
                meta: {
                    title: '结案报告'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/Closed/closedReport.vue")
            },
            {
                path: '/patientPage',
                name: 'patientPage',
                meta: {
                    title: '病人列表'
                },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/consult/patientPage.vue")
            },
            {
              path: '/rota',
              name: 'rotalist',
              meta: {
                 title: '值班信息'
              },
                component: () => import ( /* webpackChunkName: "rotalist" */ "../views/workingTime/rotaList.vue")
            },
            {
              path: '/rotaManagement',
              name: 'rotaManagement',
              meta: {
                  title: '值班管理'
              },
              component: () => import ( /* webpackChunkName: "rotaManagement" */ "../views/workingTime/rotaManagement.vue")
            },
            {
                path: "/consultManagement",
                name: "consultManagement",
                meta: {
                  title: '咨询管理'
                },
                component: () => import ( /* webpackChunkName: "consultManagement" */ "../views/consult/consultManagement.vue")
            },
            {
                path: "/firstlog",
                name: "first_visit_log",
                meta: {
                    title: '初访'
                },
                component: () => import ( /* webpackChunkName: "first_visit_log" */ "../views/firstVisit/first_visit_log.vue")
            },
            {
                path: '/timeManagement',
                name: 'workingTimeMangement',
                meta: {
                    title: '时间段管理'
                },
                component: () => import ( /* webpackChunkName: "workingTimeMangement" */ "../views/workingTime/workingTimeMangement.vue")
            },
            {
                path: "/dashboard",
                name: "dashboard",
                meta: {
                    title: '系统首页'
                },
                component: () => import ( /* webpackChunkName: "dashboard" */ "../views/Dashboard.vue")
            },

            {
                path: "/firstorder",
                name: "first_order",
                meta: {
                    title: '初访预约'
                },
                component: () => import ( /* webpackChunkName: "charts" */ "../views/firstVisit/first_order.vue")
            }, {
                path: "/form",
                name: "baseform",
                meta: {
                    title: '表单'
                },
                component: () => import ( /* webpackChunkName: "form" */ "../views/BaseForm.vue")
            }, {
                path: "/tabs",
                name: "tabs",
                meta: {
                    title: 'tab标签'
                },
                component: () => import ( /* webpackChunkName: "tabs" */ "../views/Tabs.vue")
            }, {
                path: "/donate",
                name: "donate",
                meta: {
                    title: '鼓励作者'
                },
                component: () => import ( /* webpackChunkName: "donate" */ "../views/Donate.vue")
            }, {
                path: "/permission",
                name: "permission",
                meta: {
                    title: '权限管理',
                    permission: true
                },
                component: () => import ( /* webpackChunkName: "permission" */ "../views/Permission.vue")
            }, {
                path: "/i18n",
                name: "i18n",
                meta: {
                    title: '国际化语言'
                },
                component: () => import ( /* webpackChunkName: "i18n" */ "../views/I18n.vue")
            }, {
                path: "/upload",
                name: "upload",
                meta: {
                    title: '上传插件'
                },
                component: () => import ( /* webpackChunkName: "upload" */ "../views/Upload.vue")
            }, {
                path: "/icon",
                name: "icon",
                meta: {
                    title: '自定义图标'
                },
                component: () => import ( /* webpackChunkName: "icon" */ "../views/Icon.vue")
            }, {
                path: '/404',
                name: '404',
                meta: {
                    title: '找不到页面'
                },
                component: () => import (/* webpackChunkName: "404" */ '../views/404.vue')
            }, {
                path: '/403',
                name: '403',
                meta: {
                    title: '没有权限'
                },
                component: () => import (/* webpackChunkName: "403" */ '../views/403.vue')
            }, {
                path: '/user',
                name: 'user',
                meta: {
                    title: '个人中心'
                },
                component: () => import (/* webpackChunkName: "user" */ '../views/User.vue')
            }, {
                path: '/editor',
                name: 'editor',
                meta: {
                    title: '富文本编辑器'
                },
                component: () => import (/* webpackChunkName: "editor" */ '../views/Editor.vue')
            }
        ]
    }, {
        path: "/login",
        name: "Login",
        meta: {
            title: '登录'
        },

        component: () => import ( /* webpackChunkName: "login" */ "../views/Login.vue")
    },{
        path: "/register",
        name: "Register",
        meta: {
            title: '注册'
        },

        component: () => import ( /* webpackChunkName: "Register" */ "../views/Register.vue")
    }
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

// router.beforeEach((to, from, next) => {
//     document.title = `${to.meta.title} | vue-manage-system`;
//     const role = localStorage.getItem('ms_username');
//     if (!role && to.path !== '/login') {
//         next('/login');
//     } else if (to.meta.permission) {
//         // 如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
//         role === 'admin'
//             ? next()
//             : next('/403');
//     } else {
//         next();
//     }
// });

export default router;
